package AbstractFactoryMethodPattern.example;

import AbstractFactoryMethodPattern.example.framework.*;

public class Apple extends Factory {
    @Override
    public Product createCPU(String type) {
        Product p = null;
        switch (type) {
            case "A10":
                p = new CPU("Apple A10");
                break;
            case "A11":
                p = new CPU("Apple A11");
                break;
            default:
                break;
        }
        return p;
    }

    @Override
    public Product createRAM(String type) {
        Product p = null;
        switch (type) {
            case "8G":
                p = new RAM("Apple 8G RAM");
                break;
            case "16G":
                p = new RAM("Apple 16G RAM");
                break;
            default:
                break;
        }
        return p;
    }

    @Override
    public Product createPhone(String type) {
        Product p = null;
        CPU cpu;
        RAM ram;
        switch (type) {
            case "iPhoneX":
                cpu = (CPU) createCPU("A10");
                ram = (RAM) createRAM("8G");
                p = new Phone("iPhoneX", cpu, ram);
                break;
            case "iPhoneSE":
                cpu = (CPU) createCPU("A11");
                ram = (RAM) createRAM("16G");
                p = new Phone("iPhoneX", cpu, ram);
                break;
            default:
                break;
        }
        return p;
    }

    @Override
    public Product createComputer(String type) {
        Product p = null;
        CPU cpu;
        RAM ram;
        switch (type) {
            case "MacAir":
                cpu = (CPU) createCPU("A10");
                ram = (RAM) createRAM("8G");
                p = new Phone("Mac Air 2011", cpu, ram);
                break;
            case "MacPro":
                cpu = (CPU) createCPU("A11");
                ram = (RAM) createRAM("16G");
                p = new Phone("Mac Pro 2012", cpu, ram);
                break;
            default:
                break;
        }
        return p;
    }
}
